package com.ruoyi.web.controller.airplane;

import java.util.List;
import java.util.Random;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.vo.TbDeviceAppLogsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbDeviceAppLogs;
import com.ruoyi.system.service.ITbDeviceAppLogsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备应用更新日志Controller
 *
 * @author ruoyi
 * @date 2025-07-23
 */
@Api(tags = "设备应用更新日志")
@RestController
@RequestMapping("/system/app/logs")
public class TbDeviceAppLogsController extends BaseController {
    @Autowired
    private ITbDeviceAppLogsService tbDeviceAppLogsService;

    /**
     * 查询设备应用更新日志列表
     */
    //@PreAuthorize("@ss.hasPermi('system:logs:list')")
    @Log(title = "设备应用更新日志", businessType = BusinessType.OTHER)
    @ApiOperation("查询设备应用更新日志列表")
    @GetMapping("/list")
    public R<List<TbDeviceAppLogsVO>> list(TbDeviceAppLogs tbDeviceAppLogs) {
        startPage();
        List<TbDeviceAppLogsVO> list = tbDeviceAppLogsService.selectTbDeviceAppLogsList(tbDeviceAppLogs);
        return R.ok(list);
    }




    /**
     * 导出设备应用更新日志列表
     */
//    @ApiOperation("导出设备应用更新日志列表")
//    //  @PreAuthorize("@ss.hasPermi('system:logs:export')")
//    @Log(title = "设备应用更新日志", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, TbDeviceAppLogs tbDeviceAppLogs) {
//        List<TbDeviceAppLogs> list = tbDeviceAppLogsService.selectTbDeviceAppLogsList(tbDeviceAppLogs);
//        ExcelUtil<TbDeviceAppLogs> util = new ExcelUtil<TbDeviceAppLogs>(TbDeviceAppLogs.class);
//        util.exportExcel(response, list, "设备应用更新日志数据");
//    }

    /**
     * 获取设备应用更新日志详细信息
     */
    @ApiOperation("获取设备应用更新日志详细信息")
    // @PreAuthorize("@ss.hasPermi('system:logs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tbDeviceAppLogsService.selectTbDeviceAppLogsById(id));
    }

    /**
     * 新增设备应用更新日志
     */
    @ApiOperation("新增设备应用更新日志")
    //  @PreAuthorize("@ss.hasPermi('system:logs:add')")
    @Log(title = "设备应用更新日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbDeviceAppLogs tbDeviceAppLogs) {

        return toAjax(tbDeviceAppLogsService.insertTbDeviceAppLogs(tbDeviceAppLogs));
    }

    /**
     * 修改设备应用更新日志
     */
    @ApiOperation("修改设备应用更新日志")
    // @PreAuthorize("@ss.hasPermi('system:logs:edit')")
    @Log(title = "设备应用更新日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbDeviceAppLogs tbDeviceAppLogs) {
        return toAjax(tbDeviceAppLogsService.updateTbDeviceAppLogs(tbDeviceAppLogs));
    }

    /**
     * 删除设备应用更新日志
     */
    // @PreAuthorize("@ss.hasPermi('system:logs:remove')")
    @ApiOperation("删除设备应用更新日志")
    @Log(title = "设备应用更新日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tbDeviceAppLogsService.deleteTbDeviceAppLogsByIds(ids));
    }
}
